// 深度优先搜索
    Node* flatten(Node* head) {
        function<Node*(Node*)> dfs = [&](Node *node)
        {
            Node *cur = node;
            Node *last = nullptr;
            while(cur)
            {
                Node *next = cur->next;
                if(cur->child)
                {
                    Node *child_last = dfs(cur->child);
                    next = cur->next;
                    cur->next = cur->child;
                    cur->child->prev = cur;
                    if(next)
                    {
                        child_last->next = next;
                        next->prev = child_last;
                    }
                    cur->child = nullptr;
                    last = child_last;
                }
                else
                {
                    last = cur;
                }
                cur = next;
            }
            return last;
        };
        dfs(head);
        return head;
    }